
//#include <config.h>

#include <stdio.h>
//#include <getopt.h>
//#include <sys/types.h>

//#include "system.h"
//#include "error.h"
//#include "quote.h"
//#include "xstrtol.h"

#define TAB_WIDTH 8

#define PROGRAM_NAME "fold"

#define AUTHORS "David MacKenzie"

/* The name this program was run with. */
char *program_name;

/* If nonzero, try to break on whitespace. */
//static bool break_spaces;

/* If nonzero, count bytes, not column positions. */
char count_bytes;

/* If nonzero, at least one of the files we read was standard input. */
//static bool have_read_stdin;

//static char const shortopts[] = "bsw:0::1::2::3::4::5::6::7::8::9::";

/*
static struct option const longopts[] =
{
  {"bytes", no_argument, NULL, 'b'},
  {"spaces", no_argument, NULL, 's'},
  {"width", required_argument, NULL, 'w'},
  {GETOPT_HELP_OPTION_DECL},
  {GETOPT_VERSION_OPTION_DECL},
  {NULL, 0, NULL, 0}
};

*/


adjust_column (size_t column, char c)
{
  if (!count_bytes)
    {
      if (c == '\b')
        {
          if (column > 0)
            column--;
        }
      else if (c == '\r')
        column = 0;
      else if (c == '\t')
        column += TAB_WIDTH - column % TAB_WIDTH;
      else /* if (isprint (c)) */
        column++;
    }
  else
    column++;
  return column;
}

int main (int argc, char **argv) {

  FILE *istream = stdin;
  int c;
  size_t column = 0;            /* Screen column where next char will go. */
  size_t offset_out = 0;        /* Index in `line_out' for next char. */
  static char *line_out = NULL;
  static size_t allocated_out = 0;
  int saved_errno;
/*
  while ((c = getc (istream)) != EOF)
    {

      if (c == '\n')
        {
          line_out[offset_out++] = c;
          fwrite (line_out, sizeof (char), offset_out, stdout);
          column = offset_out = 0;
          continue;
        }
*/
      klee_make_symbolic(&column, sizeof(column), "column"); 
      klee_make_symbolic(&c, sizeof(c), "c");
      klee_make_symbolic(&count_bytes, sizeof(count_bytes), "countbytes");

      column = adjust_column (column, c);

//   }

    return 0;

}
